package com.ruoyi.web.controller.student_man;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.TbAcademy;
import com.ruoyi.system.service.ITbAcademyService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 【学院】Controller
 * 
 * @author ruoyi
 * @date 2024-06-11
 */
@RestController
@RequestMapping("/studentMan/academy")
public class TbAcademyController extends BaseController
{
    @Autowired
    private ITbAcademyService tbAcademyService;

    /**
     * 查询【学院】列表
     */
//    @PreAuthorize("@ss.hasPermi('system:academy:list')")
    @GetMapping("/list")
    public TableDataInfo list(TbAcademy tbAcademy)
    {
        startPage();
        List<TbAcademy> list = tbAcademyService.selectTbAcademyList(tbAcademy);
        return getDataTable(list);
    }

    /**
     * 导出【学院】列表
     */
//    @PreAuthorize("@ss.hasPermi('system:academy:export')")
//    @Log(title = "【学院】", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TbAcademy tbAcademy)
    {
        List<TbAcademy> list = tbAcademyService.selectTbAcademyList(tbAcademy);
        ExcelUtil<TbAcademy> util = new ExcelUtil<TbAcademy>(TbAcademy.class);
        util.exportExcel(response, list, "【学院】数据");
    }

    /**
     * 获取【学院】详细信息
     */
//    @PreAuthorize("@ss.hasPermi('system:academy:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(tbAcademyService.selectTbAcademyById(id));
    }

    /**
     * 新增【学院】
     */
//    @PreAuthorize("@ss.hasPermi('system:academy:add')")
//    @Log(title = "【学院】", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TbAcademy tbAcademy)
    {
        return toAjax(tbAcademyService.insertTbAcademy(tbAcademy));
    }

    /**
     * 修改【学院】
     */
//    @PreAuthorize("@ss.hasPermi('system:academy:edit')")
//    @Log(title = "【学院】", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TbAcademy tbAcademy)
    {
        return toAjax(tbAcademyService.updateTbAcademy(tbAcademy));
    }

    /**
     * 删除【学院】
     */
//    @PreAuthorize("@ss.hasPermi('system:academy:remove')")
//    @Log(title = "【学院】", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(tbAcademyService.deleteTbAcademyByIds(ids));
    }
    /**
     * 删除【学院】
     */
//    @PreAuthorize("@ss.hasPermi('system:academy:remove')")
//    @Log(title = "【学院】", businessType = BusinessType.DELETE)
//    @DeleteMapping("/{id}")
//    public AjaxResult findById(@PathVariable Long id)
//    {
////        tbAcademyService.findId
//    }

    @GetMapping("/listAcademyMsg")
    public AjaxResult listAcademyMsg()
    {
        return success(tbAcademyService.listAcademyMsg());
    }
}
